﻿using AF_Application.Interface.App;
using AF_Application.Interface.Cache;
using AF_Application.Interface.Log;
using AF_DataModel;
using AF_IOC;
using Autofac;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using AF_Auth;
using AF_Cache.Session;
using AF_Application.Interface.Repertory;
using AF_Application.Interface.Domain;
using AF_Lucky;

namespace WebApp_Standard
{
    public partial class Index : System.Web.UI.Page
    {
        IAppImpl App = IOC.Instance.Get<IAppImpl>();
        ISessionCacheProvider SessionCacheProvider = IOC.Instance.Get<ISessionCacheProvider>();
        protected void Page_Load(object sender, EventArgs e)
        {
            //调用授权
            //WeiXinAuthHelper WeiXinAuth = new WeiXinAuthHelper();
            //WeiXinAuth.CheckAuth();

          
            string OpenId = "oAldCwh8YtT9qNsGouJWe2FwSwb8";
            if (SessionCacheProvider.Get<string>("OpenId") != null)
            {
                OpenId = SessionCacheProvider.Get<string>("OpenId");
                T_User user = App.GetUserByOpenID(OpenId);
                if (user == null)
                {

                    Response.Write("~/Authed.aspx");
                }
            }
        }

        public void WriteDebugLog(string msg)
        {
            System.IO.File.AppendAllText(Server.MapPath("~/log_" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + ".txt"), DateTime.Now.ToString() + msg + Environment.NewLine);
        }
    }
}